package com.vf.admin.miaodong.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.miaodong.entity.AppActive;
import com.vf.admin.miaodong.entity.AppUser;
import com.vf.admin.utils.StringEx;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>Title : </p>
 * <p>Description : </p>
 * <p>DevelopTools : IDEA</p>
 * <p>DevelopSystem : Windows11</p>
 *
 * @Author : zxw
 * @Date 2023/8/11 10:32
 */
@Repository
public class AfterAppActiveDao extends BaseDao<AppActive> {

    /**
     * 保存或是修改
     *
     * @param param
     */
    public void saveOrUpdate(AppActive param) {
        if (param.getId() != null && param.getId() > 0) {
            this.update(param);
        } else {
            param.setId(this.add(param));
        }
    }

    public List<AppActive> countAppActive(Map<String, Object> map) {
        List<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder(" SELECT a.* FROM app_active a where 1=1 ");
        System.out.println("入参:" + map.get("today"));
        if (map.containsKey("today") && StringEx.isNotNull(map.get("today"))) {
            sbStr.append(" and a.createtime like ? ");
            paramList.add("%" + map.get("today") + "%");
        }
        String sql = sbStr.toString();
        return this.queryList(sql, paramList, AppActive.class);
    }
}
